package jbase.project.system.core;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class InterfaceProxyFactory {

	public static InterfaceProxyFactory newInstance() {
		return new InterfaceProxyFactory();
	}

	private InterfaceProxyFactory() {
	}

	@SuppressWarnings("unchecked")
	public <T> T makeProxy(InvocationHandler handler, Class<T>... interfaceClasses) {
		return (T) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), interfaceClasses, handler);
	}

	@SuppressWarnings("unchecked")
	public <T> T makeProxy(ClassLoader classLoader, InvocationHandler handler, Class<T>... interfaceClasses) {
		return (T) Proxy.newProxyInstance(classLoader, interfaceClasses, handler);
	}

}
